package com.sk.skplanet.commute.actions;

import java.util.ArrayList;

import android.os.Handler;
import android.os.Message;
import android.util.Log;
import android.widget.LinearLayout;
import android.widget.RelativeLayout;
import android.widget.TextView;

import com.sk.skplanet.commute.R;
import com.sk.skplanet.commute.vo.Point;

public class SortingHandler extends Handler {
	private LinearLayout layout_point;
	private Point point;
	private ArrayList<LinearLayout> tvArr;

	public SortingHandler() {

	}

	public void setParameters(LinearLayout layout_point, Point point, ArrayList<LinearLayout> tvArr) {
		this.layout_point = layout_point;
		this.point = point;
		this.tvArr = tvArr;

	}

	@Override
	public void handleMessage(Message msg) {
		// TODO Auto-generated method stub

		// for (int stopinfoPosition = 0; stopinfoPosition < point.getStopInfos().size(); stopinfoPosition++) {
		// if (stopinfoPosition == 0) continue;
		// else layout_point.removeViewAt(stopinfoPosition);
		// }
		if (layout_point != null) {
			for (LinearLayout l : tvArr)
				layout_point.bringChildToFront(l);

			layout_point.invalidate();
			layout_point.postInvalidate();

			if (tvArr.size() != 0) {
				TextView t = (TextView) tvArr.get(0).findViewById(R.id.textview_busNum);
				if (t != null) t.setText(t.getText());
				Log.i("handler", "sorted");
			}
		}

	}
}
